//
//  XQThreeTableViewCell.swift
//  XiaoQiQiaoSwift
//
//  Created by tech-lab on 2016/11/28.
//  Copyright © 2016年 校企桥. All rights reserved.
//

import UIKit


class SecondCollectViewCell: UICollectionViewCell {
    var icon = UIImageView()
    var label = UILabel()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        InitUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func InitUI(){
        self.contentView.layer.borderWidth = 0.3;
        self.contentView.layer.borderColor = UIColor.lightGray.cgColor
        
        icon = UIImageView.init(frame: CGRect.zero)
        self.contentView .addSubview(icon)
        
        label = UILabel.init(frame: CGRect.zero)
        label.font = UIFont.systemFont(ofSize: 14)
        self.contentView .addSubview(label)
        
        icon.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView.snp.left).offset(15)
            make.centerY.equalTo(self.contentView.snp.centerY)
            make.width.equalTo(20)
            make.height.equalTo(20)
        }
        
        label.snp.makeConstraints { (make) in
            make.left.equalTo(icon.snp.right).offset(5)
            make.centerY.equalTo(self.contentView.snp.centerY)
        }
    }
    
}


class XQHomeThreeTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
    public var homeself = XQHomeViewController()

    var collectionView:UICollectionView!
    private let SecondCollectViewCellID = "SecondCollectViewCellID"

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        InitUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func InitUI() {
        
        
        let layout = UICollectionViewFlowLayout()
        layout.minimumLineSpacing = 0
        layout.minimumInteritemSpacing = 0
        layout.itemSize = CGSize.init(width: SCREEN_WIDTH/2, height: 40)
        
        collectionView = UICollectionView.init(frame: CGRect.init(x: 0, y: 0, width: SCREEN_WIDTH, height: 80), collectionViewLayout: layout)
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.showsVerticalScrollIndicator = false
        collectionView.showsHorizontalScrollIndicator = false
        collectionView.bounces = true
        collectionView.backgroundColor = UIColor.white
        self.contentView.addSubview(collectionView)

        self.collectionView.register(SecondCollectViewCell.self, forCellWithReuseIdentifier: SecondCollectViewCellID)

        
        
    }
    
    func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 1
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 4
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
       let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SecondCollectViewCellID, for: indexPath) as!SecondCollectViewCell
        switch indexPath.row {
        case 0:
            cell.icon.image = UIImage.init(named: "惠")
            cell.label.text = "机构培训 优惠专享"
            break
        case 1:
            cell.icon.image = UIImage.init(named: "聘")
            cell.label.text = "企业直聘 精彩专场"
            break
        case 2:
            cell.icon.image = UIImage.init(named: "精")
            cell.label.text = "精英行业 在线对话"
            break
        case 3:
            cell.icon.image = UIImage.init(named: "播")
            cell.label.text = "名师直播 免费试听"
            break

            
        default:
            break
        }
        
        return cell
        
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        switch indexPath.row {
        case 0:
            break
        case 1:
            break
        case 2:
            break
        case 3:
            break
        default:
            break
        }
    }
    


}













